from collections import Counter

words = [
    'aa','bb','cc','dd','ee','ff',
    'aa','bb','cc','dd','ee','ff',
    'aa','bb','cc','dd','ee','ff',
    'aa','bb','cc','dd','ee','ff',
    'aa','bb','cc','dd','ee','ff',
]

word_counts = Counter(words)
top_three = word_counts.most_common(3)
print(top_three)

count = word_counts['aa']
print(count)

more_words = ['aa','bb','cc']

# 手动的增加计数，将words 与 more_words 一块计数
for word in more_words:
    word_counts[word]+=1

print(word_counts['aa'])

# 将more_words 添加到 Counter 中。
word_counts.update(more_words)

print(word_counts['aa'])

counter_a = Counter(words)
counter_b = Counter(more_words)
# 两个Counter可以进行相加
counter_c = counter_a + counter_b
print(counter_c)
# 两个Counter也可以进行相加
counter_d = counter_a - counter_b
print(counter_d)

w = (
    'aa','bb','cc','dd','ee','ff',
    'aa','bb','cc','dd','ee','ff',
    'aa','bb','cc','dd','ee','ff',
    )

w_counter = Counter(w)
w_most = w_counter.most_common(2)
print(w_most)

s = "aabbccddeefff"
s_counter = Counter(s)
s_most = s_counter.most_common()
print(s_most)
